package com.yz.book.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yz.book.entity.Product;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author ste
 * @since 2023-02-04 03:37:37
 */
@Mapper
public interface ProductMapper extends BaseMapper<Product> {

    @Update("update t_product set store_count=store_count-#{buyCount} where id=#{productId} and store_count >= #{buyCount}")
    int updateBookStoreCount(Integer productId, Integer buyCount);

    @Update("update t_product set buy_count=buy_count+#{buyCount} where id=#{productId}")
    void updateBuyCount(Integer productId, Integer buyCount);
}
